<?php
//require_once "jssdk-php/jssdk.php";
//正式号
$jssdk = new JSSDK(C('appId'),C('appSelect'));

//测试号
//$jssdk = new JSSDK("wx7d706ec3d5c64bbc","8fe7b53cd192b14af27201c885df29e1");
$signPackage = $jssdk->GetSignPackage();
//dump($signPackage);die;
//const APPID = 'wx5bcbf53225e52b2b';
//const MCHID = '1900009851';
//const MCHID = '1502422011';
//const KEY = '8934e7d15453e97507ef794cf7b0519d';
//const KEY = 'Ees31807420113180742011234567811';
//const APPSECRET = '7813490da6f1265e4901ffb80afaa36f';
//const APPSECRET = 'a6d302625c8c420f87183e57241b3bd5';
//print_r($signPackage);die;
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>列表页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/app.css" />
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="__PUBLIC__/layer_mobile/layer.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <style>
        .mui-sc-icon i.btnAfter{
            width: 15px;
            height: 15px;
            background: url(__PUBLIC__/images/bizimg/heartIcon.png);
            float: left;
            background-size: 100%;
            margin-top: 2px;
            margin-right: 2px;
        }
    </style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a style="position:absolute;z-index: 2" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <a href="{:U('Time/index')}" style='position:absolute; z-index:3; width:40px; height:40px; left:0px; top:0px;background: blue;opacity:0'></a>
    <h1 class="mui-title">北京市</h1>
    <a href="{:U('search',array('ci'=>2))}" class="mui-qiehuan-icon  mui-pull-right"></a>
</header>
<div class="mui-content">
    <div class="mui-select-list">
        <i class="mui-sanjiao"></i>
        <select id="type" class="zulin-list-se" >
            <option value="D" <if condition="$type eq 'D'">selected</if> value="item-1">距离最近</option>
            <option value="L" <if condition="$type eq 'L'">selected</if> value="item-2">低价优先</option>
            <option value="H" <if condition="$type eq 'H'">selected</if> value="item-3">高价优先</option>
            <option value="B" <if condition="$type eq 'B'">selected</if> value="item-4">好评优先</option>
        </select>
    </div>
    <ul id="ul" class="mui-table-view">
        <foreach name="data" item="vo">
        <li class="mui-table-view-cell mui-media">
            <a href="javascript:;" class="wspin">
                <img onclick="location.href='{:U('detail',array('id'=>$vo[StoreID],'tel'=>$vo[Tel]))}#mp.weixin.qq.com'" class="mui-media-object mui-pull-left mui-sc-img" <if condition="$vo[Photo] eq ''">src='https://ss0.baidu.com/73x1bjeh1BF3odCf/it/u=143002432,1168190689&fm=85&s=18A27532AD89C0CA5AEDF1C20000E0B1'<else/>src="{$vo.Photo}"</if>>
                <div class="mui-media-body mui-sc-list">
                    <p onclick="location.href='{:U('detail',array('id'=>$vo[StoreID],'tel'=>$vo[Tel]))}#mp.weixin.qq.com'" class="mui-sc-p">{$vo.Name}</p>
                    <p onclick="location.href='{:U('detail',array('id'=>$vo[StoreID],'tel'=>$vo[Tel]))}#mp.weixin.qq.com'"><lable>联系人:</lable><i>{$vo.Contact}</i></p>
                    <p onclick="location.href='{:U('detail',array('id'=>$vo[StoreID],'tel'=>$vo[Tel]))}#mp.weixin.qq.com'"><lable>联系电话:</lable><i>{$vo.Tel}</i></p>
                    <button _id="{$vo.StoreID}" onclick="shoucang(this)" type="button" class="mui-btn mui-sc-icon"><i  <if condition="$vo[StoreFav] eq 'TRUE'">class="btnAfter"</if>></i> 收藏</button>
<!--
                    <button onclick="location.href='{:U('daohang',array('id'=>$vo[StoreID],'jing'=>$vo[Lng],'wei'=>$vo[Lat]))}'"  type="button" class="mui-btn mui-dh-icon"><i></i>导航</button>
-->
                    <button onclick="getLocation('{$vo.Name}',{$vo.Lng},{$vo.Lat})"  type="button" class="mui-btn mui-dh-icon"><i></i>导航</button>

<!--
                    <button onclick="location.href='http://api.map.baidu.com/direction?origin=latlng:34.264642646862,108.95108518068|name:我家&destination=大雁塔&mode=driving&region=西安&output=html&src=yourCompanyName|yourAppName'"  type="button" class="mui-btn mui-dh-icon"><i></i>导航</button>
-->
                </div>
            </a>
        </li>
        </foreach>
    </ul>
</div>
</body>
</html>
<script>
    var page = 1, //分页码
        off_on = false, //分页开关(滚动加载方法 1 中用的)
        timers = null; //定时器(滚动加载方法 2 中用的)
    //还可以基window窗口（body）来添加滚动事件, (因为布局不同,所以在这里没效果，因为[上面是基于body中的某个元素来添加滚动事的])
    $(window).scroll(function() {
        //当时滚动条离底部60px时开始加载下一页的内容
        if (($(window).height() + $(window).scrollTop() + 120) >= $(document).height()) {
            clearTimeout(timers);
            timers = setTimeout(function() {
                page++;
                //alert(page)
                $.post("{:U('fenye')}",{id:$('#type').val(),page:page},function(rels)
                {
                    if(rels.code == '1')
                    {
                        //alert(rels.str)
                        $('#ul').append(rels.str)
                    }
                })
            }, 300);
        }
    });
</script>
<script>
    $('#type').change(function () {
        var val = $(this).val()
        location.href='/index.php?g=YunCangChu&m=Time&a=lists&val='+val
    })
    //收藏仓库
    function shoucang(obj) {
        var obj = $(obj)
        if (typeof obj.children().attr('class') === "undefined") {
            $.post("{:U('setSc')}",{id:obj.attr('_id')},function (rel) {
                if(rel.code == '0')
                {
                    //提示
                    layer.open({
                        content: '收藏成功'
                        ,skin: 'msg'
                        ,time: 2
                    });
                    obj.children().attr('class','btnAfter')
                }
                else
                {
                    //提示
                    layer.open({
                        content: '收藏失败'
                        ,skin: 'msg'
                        ,time: 2
                    });
                }
            })
        }
        else
        {
            $.post("{:U('qetSc')}",{id:obj.attr('_id')},function (rel) {
                if(rel.code == '0')
                {
                    //提示
                    layer.open({
                        content: '取消收藏成功'
                        ,skin: 'msg'
                        ,time: 2
                    });
                    obj.children().attr('class','')
                }
                else
                {
                    //提示
                    layer.open({
                        content: '取消收藏失败'
                        ,skin: 'msg'
                        ,time: 2
                    });
                }
            })
        }

    }
</script>
<script>
    /*
     * 注意：
     * 1. 所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
     * 2. 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
     * 3. 常见问题及完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
     *
     * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决，如仍未能解决可通过以下渠道反馈：
     * 邮箱地址：weixin-open@qq.com
     * 邮件主题：【微信JS-SDK反馈】具体问题
     * 邮件内容说明：用简明的语言描述问题所在，并交代清楚遇到该问题的场景，可附上截屏图片，微信团队会尽快处理你的反馈。
     */
    var timestamp = "<?php echo $signPackage['timestamp'];?>";
    var nonceStr = "<?php echo $signPackage['nonceStr'];?>";
    var signature = "<?php echo $signPackage['signature'];?>";
    wx.config({
        debug: true,
        appId: '<?php echo C("appId");?>',
        timestamp: timestamp,
    nonceStr: nonceStr,
        signature: signature,
        jsApiList : [ 'chooseImage', 'uploadImage', 'downloadImage',
        'previewImage','openLocation', 'getLocation',
        'scanQRCode', 'checkJsApi', 'onMenuShareTimeline',
        'onMenuShareAppMessage', 'onMenuShareQQ',
        'onMenuShareWeibo', 'onMenuShareQZone']
    });

    wx.ready(function () {
        // 在这里调用 API
    });

    wx.error(function (res) {
          alert(res.errMsg);  //打印错误消息。及把 debug:false,设置为debug:ture就可以直接在网页上看到弹出的错误提示
      });
      http://www.php.cn/php-weizijiaocheng-376077.html

    function getLocation(names,longitude,latitude) {
        wx.getLocation({
            type : 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
            success : function(res) {
                //使用微信内置地图查看位置接口
                wx.openLocation({
                    latitude : parseFloat(latitude), // 纬度，浮点数，范围为90 ~ -90
                    longitude : parseFloat(longitude), // 经度，浮点数，范围为180 ~ -180。
                    name : names, // 位置名
                    address : '', // 地址详情说明
                    scale : 15, // 地图缩放级别,整形值,范围从1~28。默认为最大
                    infoUrl : 'http://www.gongjuji.net' // 在查看位置界面底部显示的超链接,可点击跳转（测试好像不可用）
                });
            },
            cancel : function(res) {

            }
        });
    }
</script>